<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>

    function Box(){

    }
    function Desk(){

    }
    const obj = new Box();
    console.log(obj.__proto__ === Box.prototype);
    console.log(obj.__proto__.__proto__ === Object.prototype);
    console.log(Object.prototype.__proto__);// null;

    console.log()


    function instance_of(L,R){// obj Desk
        var L = L.__proto__;// obj.__proto__
        var R = R.prototype;// Desk.prototype
        while (true){
            if(L === null) return false;
            if(L === R) return true;//   obj.__proto__.__proto__ === Desk.prototype
            L = L.__proto__;// L = obj.__proto__.__proto__.__proto__
        }
    }
    // Box的原型对象是否在obj的原型链条上。如果在返回true,否则返回false
    // console.log(obj instanceof Box);// true
    // console.log(obj instanceof Object);// true
    // console.log(obj instanceof Desk);// false

    console.log(instance_of(obj,Box));// true
    console.log(instance_of(obj,Object));// true
    console.log(instance_of(obj,Desk));// false
</script>
</html>